package com.tianqu.tms.entity;

import java.sql.Timestamp;

import com.tianqu.tms.core.base.TmsEntity;
import com.tianqu.tms.core.exception.TmsDaoException;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.dao.AssessCarInfoDao;
import com.tianqu.tms.dao.TmsDao;
import com.tianqu.tms.dto.AssessCarInfoDto;

public class AssessCarInfo extends TmsEntity {

	private static final long serialVersionUID = -689779857841541436L;
	private int id;
	private String serial;
	private String licensePlate;
	private String vin;
	private String vendorCode;
	private String modelCode;
	private int carType;
	private int color;
	private int carUse;
	private String regDate;
	private String sendCardDate;
	private int assessPirce;
	private int ownerType;
	private String carOwner;
	private String carOwnerIdCardNo;
	private String ownerOrgNo;
	private String ownerPhone;
	private String ownerAddress;
	private int insertUserId;
	private Timestamp inputTime;
	private Timestamp updateTime;
	private int updateUserId;
	public static AssessCarInfo getInstance() {
		AssessCarInfo auc = new AssessCarInfo();
		auc.setExisting(false);
		return auc;
	}

	/**
	 * 获得车辆评估信息
	 * @param serial
	 * @return
	 * @throws TmsDaoException
	 */
	public AssessCarInfo getAssessCarInfo(String serial)throws TmsDaoException{
		AssessCarInfoDao dao = (AssessCarInfoDao) TmsDao.getInstance(TmsDao.TMS_ASSESS_CAR_INFO);
		AssessCarInfoDto  dto=dao.getAssessCar(serial);
		AssessCarInfo acc = saveEntity(dto);
		return acc;
		
	}
	
	/**
	 * 插入评估报告信息
	 * @param as
	 * @throws TmsDaoException
	 */
	public void  saveAssessCarInfo(AssessCarInfo as)throws TmsDaoException{
		AssessCarInfoDao dao = (AssessCarInfoDao) TmsDao.getInstance(TmsDao.TMS_ASSESS_CAR_INFO);
		dao.saveAssessCar(saveDto(as));
	}
	
	/**
	 * 更新评估报告信息
	 * @param as
	 * @throws TmsDaoException
	 */
	public void  updateAssessCarInfo(AssessCarInfo as)throws TmsDaoException{
		AssessCarInfoDao dao = (AssessCarInfoDao) TmsDao.getInstance(TmsDao.TMS_ASSESS_CAR_INFO);
		dao.updateAssessCar(saveDto(as));
	}
	
	
	
	
	
	

	/**
	 * 转换
	 * @param Entity
	 * @return
	 */
    private AssessCarInfoDto saveDto(AssessCarInfo ass){
    		AssessCarInfoDto  dto = new AssessCarInfoDto();
    		dto.setId(ass.getId());
    		dto.setSerial(ass.getSerial());
    		dto.setLicensePlate(ass.getLicensePlate());
    		dto.setVin(ass.getVin());
    		dto.setVendorCode(ass.getVendorCode());
    		dto.setModelCode(ass.getModelCode());
    		dto.setCarType(ass.getCarType());
    		dto.setColor(ass.getColor());
    		dto.setCarUse(ass.getCarUse());
    		dto.setRegDate(ass.getRegDate());
    		dto.setSendCardDate(ass.getSendCardDate());
    		dto.setAssessPirce(ass.getAssessPirce());
    		dto.setOwnerType(ass.getOwnerType());
    		dto.setCarOwner(ass.getCarOwner());
    		dto.setCarOwnerIdCardNo(ass.getCarOwnerIdCardNo());
    		dto.setOwnerOrgNo(ass.getOwnerOrgNo());
    		dto.setOwnerPhone(ass.getOwnerPhone());
    		dto.setOwnerAddress(ass.getOwnerAddress());
    		dto.setInsertUserId(ass.getInsertUserId());
    		dto.setInputTime(ass.getInputTime());
    		dto.setUpdateTime(ass.getUpdateTime());
    		dto.setUpdateUserId(ass.getUpdateUserId());
    	return dto;
    }
	
	/**
	 * 转换
	 * @param dto
	 * @return
	 */
    private AssessCarInfo saveEntity(AssessCarInfoDto  dto){
    	AssessCarInfo ass=null;
    	if(dto!=null){
    		ass = new AssessCarInfo();
    		ass.setId(dto.getId());
    		ass.setSerial(dto.getSerial());
    		ass.setLicensePlate(dto.getLicensePlate());
    		ass.setVin(dto.getVin());
    		ass.setVendorCode(dto.getVendorCode());
    		ass.setModelCode(dto.getModelCode());
    		ass.setCarType(dto.getCarType());
    		ass.setColor(dto.getColor());
    		ass.setCarUse(dto.getCarUse());
    		ass.setRegDate(dto.getRegDate());
    		ass.setSendCardDate(dto.getSendCardDate());
    		ass.setAssessPirce(dto.getAssessPirce());
    		ass.setOwnerType(dto.getOwnerType());
    		ass.setCarOwner(dto.getCarOwner());
    		ass.setCarOwnerIdCardNo(dto.getCarOwnerIdCardNo());
    		ass.setOwnerOrgNo(dto.getOwnerOrgNo());
    		ass.setOwnerPhone(dto.getOwnerPhone());
    		ass.setOwnerAddress(dto.getOwnerAddress());
    		ass.setInsertUserId(dto.getInsertUserId());
    		ass.setInputTime(dto.getInputTime());
    		ass.setUpdateTime(dto.getUpdateTime());
    		ass.setUpdateUserId(dto.getUpdateUserId());
    	}
    	return ass;
    }
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getSerial() {
		return serial;
	}

	public void setSerial(String serial) {
		this.serial = serial;
	}

	public String getLicensePlate() {
		return licensePlate;
	}

	public void setLicensePlate(String licensePlate) {
		this.licensePlate = licensePlate;
	}

	public String getVin() {
		return vin;
	}

	public void setVin(String vin) {
		this.vin = vin;
	}

	public String getVendorCode() {
		return vendorCode;
	}

	public void setVendorCode(String vendorCode) {
		this.vendorCode = vendorCode;
	}

	public String getModelCode() {
		return modelCode;
	}

	public void setModelCode(String modelCode) {
		this.modelCode = modelCode;
	}

	public int getCarType() {
		return carType;
	}

	public void setCarType(int carType) {
		this.carType = carType;
	}

	public int getColor() {
		return color;
	}

	public void setColor(int color) {
		this.color = color;
	}

	public int getCarUse() {
		return carUse;
	}

	public void setCarUse(int carUse) {
		this.carUse = carUse;
	}

	public String getRegDate() {
		return regDate;
	}

	public void setRegDate(String regDate) {
		this.regDate = regDate;
	}

	public String getSendCardDate() {
		return sendCardDate;
	}

	public void setSendCardDate(String sendCardDate) {
		this.sendCardDate = sendCardDate;
	}


	public int getAssessPirce() {
		return assessPirce;
	}

	public void setAssessPirce(int assessPirce) {
		this.assessPirce = assessPirce;
	}

	public int getOwnerType() {
		return ownerType;
	}

	public void setOwnerType(int ownerType) {
		this.ownerType = ownerType;
	}

	public String getCarOwner() {
		return carOwner;
	}

	public void setCarOwner(String carOwner) {
		this.carOwner = carOwner;
	}

	public String getCarOwnerIdCardNo() {
		return carOwnerIdCardNo;
	}

	public void setCarOwnerIdCardNo(String carOwnerIdCardNo) {
		this.carOwnerIdCardNo = carOwnerIdCardNo;
	}

	public String getOwnerOrgNo() {
		return ownerOrgNo;
	}

	public void setOwnerOrgNo(String ownerOrgNo) {
		this.ownerOrgNo = ownerOrgNo;
	}

	public String getOwnerPhone() {
		return ownerPhone;
	}

	public void setOwnerPhone(String ownerPhone) {
		this.ownerPhone = ownerPhone;
	}

	public String getOwnerAddress() {
		return ownerAddress;
	}

	public void setOwnerAddress(String ownerAddress) {
		this.ownerAddress = ownerAddress;
	}

	public int getInsertUserId() {
		return insertUserId;
	}

	public void setInsertUserId(int insertUserId) {
		this.insertUserId = insertUserId;
	}

	public Timestamp getInputTime() {
		return inputTime;
	}

	public void setInputTime(Timestamp inputTime) {
		this.inputTime = inputTime;
	}

	public Timestamp getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Timestamp updateTime) {
		this.updateTime = updateTime;
	}

	public int getUpdateUserId() {
		return updateUserId;
	}

	public void setUpdateUserId(int updateUserId) {
		this.updateUserId = updateUserId;
	}

	@Override
	public void save() throws TmsDaoException, TmsException {

	}

}
